﻿<include file="Public:header" />
<!-- MAIN CONTENT start -->
<script>
    $(document).ready(function(){
        var _obj = {
            checkUser:function(user_id,span,url){
                var html = '';
                var attr = '';
                $.post(url,{user_id:user_id},function(xhr){
                    if(xhr.status){
                        html = '<i class="icon-ok"></i>';
                        attr = 'true';
                    }else{
                        html = xhr.info;
                        attr = 'false';
                        span.parent('div').addClass('error');
                    }
                    span.html(html);
                    span.attr('v',attr);
                    span.show();
                });
            }
        };
        var form_obj = {
            url:$("#mail-form").attr('url'),
            input_user:$("#mail-form input[name='to_user']"),
            span_user:$('#mail-form span[node-type="span-to-user-id"]')
        };

        $(form_obj.input_user).on('blur',function(){
            _obj.checkUser(form_obj.input_user.val(),form_obj.span_user,form_obj.url);
        });
        $('#send_mail').on('click',function(){
            _obj.checkUser(form_obj.input_user.val(),form_obj.span_user,form_obj.url);
            if('true' != form_obj.span_user.attr('v')){
                return false;
            }
        });
    });

</script>

<div class="span3">
    <div class="well" style="padding: 8px 0;">
        <ul class="nav nav-list">
            <p>
                <div class="btn-group" data-toggle="buttons-radio">
                    <button class="btn" style="width: 120px;" onclick="location.href='{:U(\'Mail/index\')}'">
                        <span class="icon-inbox"></span>收信
                    </button>
                    <button class="btn active" style="width: 120px;" onclick="location.href='{:U(\'Mail/add\')}'">
                        <span class="icon-edit"></span>发信
                    </button>
                </div>
            </p>
            <li class="nav-header">
                个人信息
            </li>
            <li>
                <i class="icon-time"></i>名次：{$solution.rangking}
            </li>
            <li class="divider">
            </li>
            <li>
                <a href="{:U('/Status/index/',array('user_id'=>$user['user_id'],'result'=>4))}">
                    <i class="icon-check"></i>解决：{$solution.ac_num}
                </a>

            </li>
            <li>
                <a href="{:U('/Status/index/',array('user_id'=>$user['user_id']))}">
                    <i class="icon-list-alt"></i>提交：{$solution.sub_num}
                </a>
                <ul class="nav nav-list">
                    <foreach name="solution.solution_info" item="v_so">
                        <li>
                            <i class="icon-flag"></i>{$v_so.name}：{$v_so.num}
                        </li>
                    </foreach>
                </ul>
            </li>
            <li class="divider">
            </li>
            <li>
                <i class="icon-folder-open"></i>学校：{$user.school}
            </li>
            <li class="active">
                <i class="icon-ok"></i>邮箱：{$user.email}
            </li>
            <li class="divider">
            </li>
            <li>
                <a href="#">
                    <i class="icon-comment"></i>论坛
                </a>
            </li>
        </ul>
    </div>
</div>
<!--发信-->
<div class="span9" id="new_mail">
    <h3>
        {$user.user_id}--{$user.nick}&nbsp;&nbsp;&nbsp;Messages
    </h3>
    <form class="form-inline" action="{:U('Mail/add')}" method="post" id="mail-form" url="{:U('Mail/ajaxCheck')}">
        <fieldset>
            <legend>Write short mail</legend>
            <div class="control-group">
                <label class="control-label" for="input01">To&nbsp;&nbsp;:</label>
                <input type="text" class="input-xlarge" id="input01" value="{$user_id}" name="to_user" placeholder="User ID">*
                <span class="help-inline" node-type="span-to-user-id" style="display: none;color: red;" v="">sss</span>
            </div>
            <div class="control-group">
                <label class="control-label" for="input01">Title:</label>
                <input type="text" class="input-xlarge" id="input01"  name="title"/>
            </div>
            <div class="control-group">
                <div class="controls">
                    <!-- 加载编辑器的容器 -->
                    <script id="mail_content" name="content" ></script>
                    <!-- 配置文件 -->
                    <script type="text/javascript" src="__PUBLIC__/ueditor/ueditor.config.js"></script>
                    <!-- 编辑器源码文件 -->
                    <script type="text/javascript" src="__PUBLIC__/ueditor/ueditor.all.js"></script>
                    <!-- 实例化编辑器 -->
                    <script type="text/javascript">
                        var ue = UE.getEditor('mail_content',{
                            toolbars: [[
                                'fullscreen', 'source', '|', 'undo', 'redo', '|',
                                'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|',
                                'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
                                'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
                                'directionalityltr', 'directionalityrtl', 'indent', '|',
                                'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|', 'emotion',  'insertcode', '|',
                                'horizontal', 'date', 'time', 'spechars','|',
                                'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol', 'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols', 'charts', '|',
                                'print', 'preview', 'searchreplace', 'help', 'drafts'
                            ]]
                        });
                    </script>
                </div>
            </div>
            <div class="form-actions">
                <button type="submit" class="btn btn-primary" id="send_mail">Send</button>
                <button class="btn" type="button" onclick="javascrip:tab_exchange('mail_list','new_mail')">Cancel</button>
            </div>
        </fieldset>
    </form>
</div>

<!-- MAIN CONTENT -->
<include file="Public:footer" />